package org.vt.scheduleapp;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import android.content.Context;

public class ToDoReader {

	private final String FILENAME = "todoList_file.txt";
	private FileInputStream fis;
	private final String colon = "[:]";
	private final String period = "[.]";
	private Context mCtx;

	public ToDoReader(Context context)
	{
		mCtx = context;
	}

	public List<ToDoList> getAllTodo() throws IOException, FileNotFoundException
	{
		fis  = mCtx.openFileInput(FILENAME);
		List<ToDoList> todo = new ArrayList<ToDoList>();
		BufferedReader br = new BufferedReader(new InputStreamReader(fis));
		String line = br.readLine();
		while((line = br.readLine())!= null)
		{		
		
			String[] t1 = line.split(period);
			String[]n = t1[0].split(colon);
			String todoName = n[1];
			todo.add(new ToDoList(todoName));
		}
		fis.close();
		return todo;
	}
}
